package com.zzb.spirng.aop.impl;

import java.util.Arrays;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

//验证切面
@Order(1)
@Aspect
@Component
public class VlidationAspect {

	/*
	 * 定义一个方法，用于声明切入点(目标方法)表达式，一般的，该方法中再不需要填入其他的代码
	 */
	@Pointcut("execution(public int com.zzb.spirng.aop.impl.ArithmeticCalculator.*(int, int))")
	public void declareJointPointExpression(){}
	
	@Before("declareJointPointExpression()")
	private void vlidateArgs(JoinPoint joinpoint){
		System.out.println("-->vlidation:" + Arrays.asList(joinpoint.getArgs()));
	}
	
	@After("declareJointPointExpression()")
	public void afterMethod(JoinPoint joinPoint) {
		String methodName = joinPoint.getSignature().getName();
		System.out.println("-->vlidation:" + " ends");
	}
}
